home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 February / macformat-047.iso / Shareware Plus / Developers / The Gray Council 1.2.1 / projects / MacApp / UMyApplication.cp < prev    next >
Encoding:
Text File  |  1996-11-06  |  26.9 KB  |  868 lines  |  [TEXT/CWIE]

  1. //
  2. // GrayCouncil
  3. // Copyright ©1996 by Trygve Isaacson. All Rights Reserved.
  4. //
  5. // This file contains the GrayCouncil MacApp test program's
  6. // application class implementation.
  7. //
  8.  
  9. #include "UMyApplication.h"
  10.  
  11. #include "MyConstants.h"
  12.  
  13. //
  14. // TMyApplication -------------------------------------------------------------------------
  15. //
  16.  
  17. #undef Inherited
  18. #define Inherited TApplication
  19.  
  20. #pragma segment AMyApplication
  21. MA_DEFINE_CLASS_M1(TMyApplication, Inherited);
  22.  
  23. TMyApplication::TMyApplication()
  24.     {
  25.     // Init the pointers & stuff used during idling.
  26.     mProgressIndicator1 = NULL;
  27.     mProgressIndicator2 = NULL;
  28.     mMovingProgressOrigin = false;
  29.     mSkipNext = false;
  30.     }
  31.  
  32. TMyApplication::~TMyApplication()
  33.     {
  34.     }
  35.  
  36. void TMyApplication::IMyApplication()
  37.     {
  38.     FailOSErr(InitGrayCouncilMA());
  39.  
  40.     this->IApplication('????', '????');
  41.     
  42.     // Tell MacApp we don't want an Untitled document created at launch.
  43.     fLaunchWithNewDocument = false;
  44.     
  45.     this->SetIdleFreq(2);
  46.     
  47.     // Create our main window.
  48.  
  49.     TWindow* aWindow;
  50.     FailNIL(aWindow = gViewServer->NewTemplateWindow(kMainWindowViewID, NULL));
  51.     aWindow->Open();
  52.     
  53.     // Allow the window to be resized, but no smaller than
  54.     // its initial size.
  55.     
  56.     CRect    windowFrame;    
  57.     CPoint    minWindowSize;
  58.     CPoint    maxWindowSize(kMaxCoord, kMaxCoord);
  59.     
  60.     aWindow->GetQDExtent(windowFrame);
  61.     minWindowSize = windowFrame[botRight] - windowFrame[topLeft];
  62.  
  63.     aWindow->SetResizeLimits(minWindowSize, maxWindowSize);
  64.     }
  65.  
  66. void TMyApplication::DoSetupMenus()
  67.     {
  68.     Inherited::DoSetupMenus();
  69.     
  70.     // Enable all of the Test menu commands.
  71.     for (UInt32 i = 0; i < kNumDialogs; i++)
  72.         Enable(kMyCommandBase + i, true);
  73.     }
  74.  
  75. void TMyApplication::DoMenuCommand(CommandNumber aCommand)
  76.     {
  77.     // Handle the Test menu commands.
  78.  
  79.     if ((aCommand - kMyCommandBase >= 0) &&
  80.         (aCommand - kMyCommandBase < kNumDialogs))
  81.         this->PoseExampleDialog(aCommand - kMyCommandBase);
  82.     else
  83.         Inherited::DoMenuCommand(aCommand);
  84.     }
  85.  
  86. void TMyApplication::DoEvent(EventNumber eventNumber, TEventHandler* source, TEvent* event)
  87.     {
  88.     IDType        sourceID = source->GetIdentifier();
  89.     UInt32        buttonDialogIndex = sourceID;    // main window buttons are ID'd as kMyViewBase + dialogIndex
  90.  
  91.     if ((buttonDialogIndex >= kMyViewBase) && (buttonDialogIndex < (kMyViewBase + kNumDialogs)))
  92.         this->PoseExampleDialog(buttonDialogIndex - kMyViewBase);
  93.     else
  94.         {
  95.         switch (sourceID)
  96.             {
  97.             case 'ENAB':
  98.                 {
  99.                 // Enable or disable everything in the button's dialog.
  100.  
  101.                 TCheckBox*    aCheckBox = (TCheckBox*) source;
  102.                 TWindow*    aWindow = aCheckBox->GetWindow();
  103.                 
  104.                 this->EnableDisableDialog(mCurrentDialogIndex, aWindow, aCheckBox->IsOn());
  105.                 }
  106.                 break;
  107.             case 'SBAR':
  108.                 {
  109.                 // The scroll bar dialog's TScrollBar was hit.
  110.                 // Update the text that displays the TScrollBar value.
  111.  
  112.                 TScrollBar*        aScrollBar = (TScrollBar*) source;
  113.                 TWindow*        aWindow = aScrollBar->GetWindow();
  114.                 TStaticText*    valueText = (TStaticText*) aWindow->FindSubView('SBTX');
  115.                 SInt32            scrollBarValue = aScrollBar->GetLongVal();
  116.                 CStr255            valueString;
  117.                 
  118.                 ::NumToString(scrollBarValue, valueString);
  119.                 
  120.                 valueText->SetText(valueString, kRedraw);
  121.                 }
  122.                 break;
  123.             case 'LIVE':
  124.             case 'PROP':
  125.                 {
  126.                 // The scroll bar dialog had one of its checkboxes hit.
  127.                 // Toggle the appropriate attribute of the 3 scroll bars
  128.                 // in the dialog.
  129.  
  130.                 AGAScrollerScrollBarMA*    aScrollerScrollBar;
  131.                 TWindow*    aWindow = ((TCheckBox*) source)->GetWindow();
  132.                 TCheckBox*    liveCheckBox = (TCheckBox*) aWindow->FindSubView('LIVE');
  133.                 TCheckBox*    propCheckBox = (TCheckBox*) aWindow->FindSubView('PROP');
  134.  
  135.                 aScrollerScrollBar = (AGAScrollerScrollBarMA*) aWindow->FindSubView('HSBR');
  136.                 aScrollerScrollBar->mAGAObject->SetAttributes(AGAObject::kHorizontal, liveCheckBox->IsOn(), propCheckBox->IsOn());
  137.                 aScrollerScrollBar->UpdateScrollAmounts();
  138.                 
  139.                 if (sourceID == 'PROP')
  140.                     aScrollerScrollBar->ForceRedraw();
  141.  
  142.                 aScrollerScrollBar = (AGAScrollerScrollBarMA*) aWindow->FindSubView('VSBR');
  143.                 aScrollerScrollBar->mAGAObject->SetAttributes(AGAObject::kVertical, liveCheckBox->IsOn(), propCheckBox->IsOn());
  144.                 aScrollerScrollBar->UpdateScrollAmounts();
  145.                 
  146.                 if (sourceID == 'PROP')
  147.                     aScrollerScrollBar->ForceRedraw();
  148.  
  149.                 AGAScrollBarMA*    aScrollBar = (AGAScrollBarMA*) aWindow->FindSubView('SBAR');
  150.                 aScrollBar->mAGAObject->SetAttributes(AGAObject::kHorizontal, liveCheckBox->IsOn(), propCheckBox->IsOn());
  151.                 
  152.                 if (sourceID == 'PROP')
  153.                     aScrollBar->ForceRedraw();
  154.                 }
  155.                 break;
  156.  
  157.             case 'LVSL':
  158.             case 'PRSL':
  159.                 {
  160.                 // The slider dialog had one of its checkboxes hit.
  161.                 // Toggle the appropriate attribute of all sliders
  162.                 // in the dialog.
  163.  
  164.                 AGASliderMA*    aSlider;
  165.                 TWindow*        aWindow = ((TCheckBox*) source)->GetWindow();
  166.                 TCheckBox*        liveCheckBox = (TCheckBox*) aWindow->FindSubView('LVSL');
  167.                 TCheckBox*        propCheckBox = (TCheckBox*) aWindow->FindSubView('PRSL');
  168.  
  169.                 aSlider = (AGASliderMA*) aWindow->FindSubView('VSPL');
  170.                 aSlider->mAGAObject->SetAttributes(AGAObject::kVertical, liveCheckBox->IsOn(), propCheckBox->IsOn());
  171.                 if (sourceID == 'PRSL') aSlider->ForceRedraw();
  172.  
  173.                 aSlider = (AGASliderMA*) aWindow->FindSubView('VSPR');
  174.                 aSlider->mAGAObject->SetAttributes(AGAObject::kVertical, liveCheckBox->IsOn(), propCheckBox->IsOn());
  175.                 if (sourceID == 'PRSL') aSlider->ForceRedraw();
  176.  
  177.                 aSlider = (AGASliderMA*) aWindow->FindSubView('VSRC');
  178.                 aSlider->mAGAObject->SetAttributes(AGAObject::kVertical, liveCheckBox->IsOn(), propCheckBox->IsOn());
  179.                 if (sourceID == 'PRSL') aSlider->ForceRedraw();
  180.  
  181.                 aSlider = (AGASliderMA*) aWindow->FindSubView('HSPL');
  182.                 aSlider->mAGAObject->SetAttributes(AGAObject::kHorizontal, liveCheckBox->IsOn(), propCheckBox->IsOn());
  183.                 if (sourceID == 'PRSL') aSlider->ForceRedraw();
  184.  
  185.                 aSlider = (AGASliderMA*) aWindow->FindSubView('HSPR');
  186.                 aSlider->mAGAObject->SetAttributes(AGAObject::kHorizontal, liveCheckBox->IsOn(), propCheckBox->IsOn());
  187.                 if (sourceID == 'PRSL') aSlider->ForceRedraw();
  188.  
  189.                 aSlider = (AGASliderMA*) aWindow->FindSubView('HSRC');
  190.                 aSlider->mAGAObject->SetAttributes(AGAObject::kHorizontal, liveCheckBox->IsOn(), propCheckBox->IsOn());
  191.                 if (sourceID == 'PRSL') aSlider->ForceRedraw();
  192.                 }
  193.                 break;
  194.  
  195.             case 'BIGP':
  196.             case 'LILP':
  197.                 {
  198.                 TPicture*    thePicture = (TPicture*) ((TView*) source)->GetWindow()->FindSubView('PICT');
  199.                 
  200.                 thePicture->SetPictureRsrcID((sourceID == 'BIGP') ? kBigPictureID : kLittlePictureID, kRedraw);
  201.  
  202.                 CRect    pictFrame = (**(thePicture->fDataHandle)).picFrame;
  203.                 VPoint    pictSize(pictFrame[botRight] - pictFrame[topLeft]);
  204.                 
  205.                 thePicture->Resize(pictSize, kInvalidate);
  206.                 }
  207.                 break;
  208.  
  209.             case 'LRGT':
  210.             case 'SMLT':
  211.                 {
  212.                 AGATabPanelMA*        tabPanel;
  213.                 Boolean                small = (sourceID == 'SMLT');
  214.                 
  215.                 tabPanel = (AGATabPanelMA*) ((TView*) source)->GetWindow()->FindSubView('TAB1');
  216.                 tabPanel->mAGAObject->SetTabSize(small ? AGATabPanel::kSmallTabs : AGATabPanel::kLargeTabs);
  217.                 tabPanel->mAGAObject->SetLabelsStyle(small ? gAGAStdBoldSmallStyle : gAGAStdSystemStyle);
  218.                 tabPanel->ForceRedraw();
  219.                 
  220.                 tabPanel = (AGATabPanelMA*) ((TView*) source)->GetWindow()->FindSubView('TAB2');
  221.                 tabPanel->mAGAObject->SetTabSize(small ? AGATabPanel::kSmallTabs : AGATabPanel::kLargeTabs);
  222.                 tabPanel->mAGAObject->SetLabelsStyle(small ? gAGAStdBoldSmallStyle : gAGAStdSystemStyle);
  223.                 tabPanel->ForceRedraw();
  224.                 }
  225.                 break;
  226.  
  227.             case 'GO_1':
  228.                 {
  229.                 // Save the pointer to the indeterminate progress indicator,
  230.                 // so we'll increment it at idle. Swap the enable states
  231.                 // of its Go and Stop buttons.
  232.  
  233.                 TButton*    buttonToDisable = (TButton*) source;
  234.                 TWindow*    aWindow = buttonToDisable->GetWindow();
  235.                 TButton*    buttonToEnable = (TButton*) aWindow->FindSubView('STP1');
  236.                 
  237.                 this->ToggleButtons(buttonToDisable, buttonToEnable);
  238.                 
  239.                 mProgressIndicator1 = (AGAProgressIndicatorMA*) aWindow->FindSubView('PRG1');
  240.                 
  241.                 mProgressIndicator1->StartAutoAnimate();
  242.                 }
  243.                 break;
  244.             
  245.             case 'GO_2':
  246.                 {
  247.                 // Null the pointer to the determinate progress indicator,
  248.                 // so we'll ignore it at idle. Swap the enable states
  249.                 // of its Go and Stop buttons.
  250.  
  251.                 TButton*    buttonToDisable = (TButton*) source;
  252.                 TWindow*    aWindow = buttonToDisable->GetWindow();
  253.                 TButton*    buttonToEnable = (TButton*) aWindow->FindSubView('STP2');
  254.                 
  255.                 this->ToggleButtons(buttonToDisable, buttonToEnable);
  256.                 
  257.                 mProgressIndicator2 = (AGAProgressIndicatorMA*) aWindow->FindSubView('PRG2');
  258.                 }
  259.                 break;
  260.             
  261.             case 'STP1':
  262.                 {
  263.                 // Save the pointer to the indeterminate progress indicator,
  264.                 // so we'll increment it at idle. Swap the enable states
  265.                 // of its Go and Stop buttons.
  266.  
  267.                 TButton*    buttonToDisable = (TButton*) source;
  268.                 TWindow*    aWindow = buttonToDisable->GetWindow();
  269.                 TButton*    buttonToEnable = (TButton*) aWindow->FindSubView('GO_1');
  270.                 
  271.                 this->ToggleButtons(buttonToDisable, buttonToEnable);
  272.                 
  273.                 mProgressIndicator1 = (AGAProgressIndicatorMA*) aWindow->FindSubView('PRG1');
  274.                 
  275.                 mProgressIndicator1->StopAutoAnimate();
  276.  
  277.                 mProgressIndicator1 = NULL;
  278.                 }
  279.                 break;
  280.             
  281.             case 'STP2':
  282.                 {
  283.                 // Null the pointer to the indeterminate progress indicator,
  284.                 // so we'll ignore it at idle. Swap the enable states
  285.                 // of its Go and Stop buttons.
  286.  
  287.                 TButton*    buttonToDisable = (TButton*) source;
  288.                 TWindow*    aWindow = buttonToDisable->GetWindow();
  289.                 TButton*    buttonToEnable = (TButton*) aWindow->FindSubView('GO_2');
  290.                 
  291.                 this->ToggleButtons(buttonToDisable, buttonToEnable);
  292.                 
  293.                 mProgressIndicator2 = NULL;
  294.                 }
  295.                 break;
  296.             
  297.             case 'CORG':
  298.                 {
  299.                 // The progress dialog's "Moving Origin" checkbox was hit.
  300.                 // Enable or disable the edit text and little arrows, and
  301.                 // set our flag that we'll check at idle.
  302.  
  303.                 TCheckBox*    aCheckBox = (TCheckBox*) source;
  304.                 TWindow*    aWindow = aCheckBox->GetWindow();
  305.                 Boolean        enabled = aCheckBox->IsOn();
  306.                 TControl*    aControl;
  307.                 
  308.                 aControl = (TControl*) aWindow->FindSubView('NORG');
  309.                 ((TEditText*) aControl)->StopEdit();
  310.                 aControl->SetEnable(enabled);
  311.                 aControl->DimState(! enabled, kRedraw);
  312.                 
  313.                 aControl = (TControl*) aWindow->FindSubView('AORG');
  314.                 aControl->SetEnable(enabled);
  315.                 aControl->DimState(! enabled, kRedraw);
  316.                 
  317.                 aControl = (TControl*) aWindow->FindSubView('TORG');
  318.                 aControl->SetEnable(enabled);
  319.                 aControl->DimState(! enabled, kRedraw);
  320.                 
  321.                 mMovingProgressOrigin = enabled;
  322.                 }
  323.                 break;
  324.             
  325.             case 'SETV':
  326.                 {
  327.                 // The "Set Values" button in the progress dialog was hit.
  328.                 // Poke the determinate progress indicator with the current
  329.                 // values that have been entered in the dialog.
  330.  
  331.                 TWindow*        aWindow = ((TButton*) source)->GetWindow();
  332.                 TNumberText*    aNumberText;
  333.                 TCheckBox*        originCheckBox = (TCheckBox*) aWindow->FindSubView('CORG');
  334.                 SInt32            newMin;
  335.                 SInt32            newMax;
  336.                 SInt32            newValue;
  337.                 SInt32            newOrigin;
  338.  
  339.                 AGAProgressIndicatorMA*    indicator = (AGAProgressIndicatorMA*) aWindow->FindSubView('PRG2');
  340.                 
  341.                 aNumberText = (TNumberText*) aWindow->FindSubView('NMIN');
  342.                 newMin = aNumberText->GetValue();
  343.                 
  344.                 aNumberText = (TNumberText*) aWindow->FindSubView('NMAX');
  345.                 newMax = aNumberText->GetValue();
  346.                 
  347.                 indicator->mAGAObject->SetRange(newMin, newMax, kDontRedraw);
  348.                 
  349.                 aNumberText = (TNumberText*) aWindow->FindSubView('NVAL');
  350.                 newValue = aNumberText->GetValue();
  351.                 indicator->mAGAObject->SetValue(newValue, kDontRedraw);
  352.                 
  353.                 if (! originCheckBox->IsOn())
  354.                     newOrigin = newMin;
  355.                 else
  356.                     {
  357.                     aNumberText = (TNumberText*) aWindow->FindSubView('NORG');
  358.                     newOrigin = Max(newMin, aNumberText->GetValue());
  359.                     }
  360.                 
  361.                 indicator->mAGAObject->SetOriginValue(newOrigin, kDontRedraw);
  362.                 
  363.                 indicator->ForceRedraw();
  364.                 }
  365.                 break;
  366.  
  367.             case 'EDCB':
  368.                 {
  369.                 // Enable or disable the first field of the edit text dialog.
  370.  
  371.                 TCheckBox*    aCheckBox = (TCheckBox*) source;
  372.                 TWindow*    aWindow = aCheckBox->GetWindow();
  373.                 Boolean        enabled = aCheckBox->IsOn();
  374.                 TEditText*    anEditText = (TEditText*) aWindow->FindSubView('EDT1');
  375.  
  376.                 anEditText->StopEdit();
  377.                 anEditText->SetEnable(enabled);
  378.                 anEditText->DimState(! enabled, kRedraw);
  379.                 }
  380.                 break;
  381.  
  382.             }
  383.         }
  384.     
  385.     Inherited::DoEvent(eventNumber, source, event);
  386.     }
  387.  
  388. void TMyApplication::ToggleButtons(TButton* buttonToDisable, TButton* buttonToEnable)
  389.     {
  390.     buttonToDisable->SetEnable(false);
  391.     buttonToDisable->DimState(true, kRedraw);
  392.  
  393.     buttonToEnable->SetEnable(true);
  394.     buttonToEnable->DimState(false, kRedraw);
  395.     }
  396.  
  397. Boolean TMyApplication::DoIdle(IdlePhase /*phase*/)
  398.     {
  399.     // If we have a pointer to the indeterminate progress indicator,
  400.     // crank it once.
  401. //    if (mProgressIndicator1 != NULL)
  402. //        if (mProgressIndicator1->Focus())
  403. //            mProgressIndicator1->mAGAObject->Animate();
  404.  
  405.     // If we have a pointer to the determinate progress indicator,
  406.     // increment its value.
  407.     if (mProgressIndicator2 != NULL)
  408.         if (mProgressIndicator2->Focus())
  409.             {
  410.             mProgressIndicator2->mAGAObject->Increment(1, kRedraw);
  411.             
  412.             // Increment the origin every other time, if it's moving.
  413.             if (mMovingProgressOrigin && ! mSkipNext)
  414.                 mProgressIndicator2->mAGAObject->SetOriginValue(1 + mProgressIndicator2->mAGAObject->GetOriginValue(), kRedraw);
  415.             
  416.             mSkipNext = ! mSkipNext;    // make moving origin go slower than value
  417.             }
  418.  
  419.     return false;    // did not free self
  420.     }
  421.  
  422. void TMyApplication::PoseExampleDialog(UInt32 dialogIndex)
  423.     {
  424.     // Run the specified dialog.
  425.  
  426.     TWindow    *aWindow;
  427.  
  428.     FailNIL(aWindow = gViewServer->NewTemplateWindow(kMyViewBase + dialogIndex, NULL));
  429.     
  430.     mCurrentDialogIndex = dialogIndex;
  431.     
  432.     this->SetupExampleDialog(dialogIndex, aWindow);
  433.     
  434.     (void) aWindow->PoseModally();
  435.     
  436.     this->CleanupExampleDialog(dialogIndex, aWindow);
  437.     
  438.     aWindow->CloseAndFree();
  439.     }
  440.  
  441. void TMyApplication::SetupExampleDialog(UInt32 dialogIndex, TWindow* itsWindow)
  442.     {
  443.     // Note that when we set AGAObject states & values here, we tell it
  444.     // not to redraw right now, because the dialog isn't visible yet.
  445.     // If we *did* tell it to redraw, we would have to Focus() it first
  446.     // so that the AGAObject would be drawing into the correct GrafPort.
  447.  
  448.     switch (dialogIndex)
  449.         {
  450.         case kCheckBoxDlgIndex:
  451.             {
  452.             AGACheckBoxMA*    mixedCheckBox;
  453.             FailNIL(mixedCheckBox = (AGACheckBoxMA*) itsWindow->FindSubView('BTN3'));
  454.             mixedCheckBox->mAGAObject->SetValue(AGACheckBox::kCheckBoxMixed, AGAObject::kDontRedraw);
  455.             }
  456.             break;
  457.         case kRadioButtonDlgIndex:
  458.             {
  459.             AGARadioButtonMA*    mixedRadioButton;
  460.             FailNIL(mixedRadioButton = (AGARadioButtonMA*) itsWindow->FindSubView('BTN3'));
  461.             mixedRadioButton->mAGAObject->SetValue(AGARadioButton::kRadioButtonMixed, AGAObject::kDontRedraw);
  462.             }
  463.             break;
  464.         case kScrollBarDlgIndex:
  465.             {
  466.             AGAScrollBarMA    *aScrollBar = (AGAScrollBarMA*) itsWindow->FindSubView('SBAR');
  467.             aScrollBar->mAGAObject->SetPageSize(25, AGAObject::kDontRedraw);
  468.             aScrollBar->mAGAObject->SetStepSizes(1, 25);
  469.             }
  470.             break;
  471.         case kSliderDlgIndex:
  472.             {
  473.             AGASliderMA*    aSlider;
  474.  
  475.             FailNIL(aSlider = (AGASliderMA*) itsWindow->FindSubView('HSPL'));
  476.             aSlider->mAGAObject->SetRange(0, 100, AGAObject::kDontRedraw);
  477.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  478.  
  479.             FailNIL(aSlider = (AGASliderMA*) itsWindow->FindSubView('VSPR'));
  480.             aSlider->mAGAObject->SetJustification(teFlushRight);
  481.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  482.  
  483.             FailNIL(aSlider = (AGASliderMA*) itsWindow->FindSubView('HSPR'));
  484.             aSlider->mAGAObject->SetJustification(teFlushRight);
  485.             aSlider->mAGAObject->SetRange(0, 32, AGAObject::kDontRedraw);
  486.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  487.  
  488.             FailNIL(aSlider = (AGASliderMA*) itsWindow->FindSubView('VSPL'));
  489.             aSlider->mAGAObject->SetPageSize(1, AGAObject::kDontRedraw);
  490.  
  491.             FailNIL(aSlider = (AGASliderMA*) itsWindow->FindSubView('VSRC'));
  492.             aSlider->mAGAObject->SetRange(0, 100, AGAObject::kDontRedraw);
  493.             aSlider->mAGAObject->SetPageSize(20, AGAObject::kDontRedraw);
  494.  
  495.             FailNIL(aSlider = (AGASliderMA*) itsWindow->FindSubView('HSRC'));
  496.             aSlider->mAGAObject->SetRange(0, 100, AGAObject::kDontRedraw);
  497.             aSlider->mAGAObject->SetPageSize(20, AGAObject::kDontRedraw);
  498.             }
  499.             break;
  500.         case kDisclosureDlgIndex:
  501.             {
  502.             AGADisclosureTriangleMA*    aTriangle;
  503.             FailNIL(aTriangle = (AGADisclosureTriangleMA*) itsWindow->FindSubView('DIS3'));
  504.             aTriangle->mAGAObject->SetState(AGADisclosureTriangle::kDisclosedState, AGAObject::kDontRedraw);
  505.             }
  506.             break;
  507.         case kProgressDlgIndex:
  508.             {
  509.             AGAProgressIndicatorMA*    aProgressIndicator;
  510.             FailNIL(aProgressIndicator = (AGAProgressIndicatorMA*) itsWindow->FindSubView('PRG1'));
  511.             aProgressIndicator->mAGAObject->SetRange(0, 0, AGAObject::kDontRedraw);
  512.             }
  513.             break;
  514.         case kFolderTabsDlgIndex:
  515.             {
  516.             AGATabPanelMA*    tabPanel;
  517.             
  518.             FailNIL(tabPanel = (AGATabPanelMA*) itsWindow->FindSubView('TAB1'));
  519.             
  520.             tabPanel->InstallPanel(0, 3000, NULL);
  521.             tabPanel->InstallPanel(1, 3001, NULL);
  522.             tabPanel->InstallPanel(2, 3002, NULL);
  523.             }
  524.             break;
  525.         }
  526.     }
  527.  
  528. void TMyApplication::CleanupExampleDialog(UInt32 dialogIndex, TWindow* /*itsWindow*/)
  529.     {
  530.     switch (dialogIndex)
  531.         {
  532.         case kProgressDlgIndex:
  533.             {
  534.             // Null the pointers so we don't go haywire at next DoIdle !
  535.  
  536.             mProgressIndicator1 = NULL;
  537.             mProgressIndicator2 = NULL;
  538.             mMovingProgressOrigin = false;
  539.             mSkipNext = false;
  540.             }
  541.             break;
  542.         }
  543.     }
  544.  
  545. void TMyApplication::EnableDisableDialog(UInt32 dialogIndex, TWindow* itsWindow, Boolean enable)
  546.     {
  547.     // Find all of the appropriate items of the specified dialog,
  548.     // and set their enable/disable/dim state as requested.
  549.  
  550.     TControl*    aControl;
  551.     TView*        aView;
  552.     
  553.     switch (dialogIndex)
  554.         {
  555.         case kPushButtonDlgIndex:
  556.  
  557.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN1'));
  558.             aControl->SetEnable(enable);
  559.             aControl->DimState(! enable, kRedraw);
  560.             
  561.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN2'));
  562.             aControl->SetEnable(enable);
  563.             aControl->DimState(! enable, kRedraw);
  564.             
  565.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN1'));
  566.             aControl->SetEnable(enable);
  567.             aControl->DimState(! enable, kRedraw);
  568.             
  569.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN2'));
  570.             aControl->SetEnable(enable);
  571.             aControl->DimState(! enable, kRedraw);
  572.             
  573.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN3'));
  574.             aControl->SetEnable(enable);
  575.             aControl->DimState(! enable, kRedraw);
  576.             
  577.             break;
  578.  
  579.         case kCheckBoxDlgIndex:
  580.  
  581.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN1'));
  582.             aControl->SetEnable(enable);
  583.             aControl->DimState(! enable, kRedraw);
  584.             
  585.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN2'));
  586.             aControl->SetEnable(enable);
  587.             aControl->DimState(! enable, kRedraw);
  588.             
  589.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN3'));
  590.             aControl->SetEnable(enable);
  591.             aControl->DimState(! enable, kRedraw);
  592.             
  593.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN1'));
  594.             aControl->SetEnable(enable);
  595.             aControl->DimState(! enable, kRedraw);
  596.             
  597.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN2'));
  598.             aControl->SetEnable(enable);
  599.             aControl->DimState(! enable, kRedraw);
  600.             
  601.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN3'));
  602.             aControl->SetEnable(enable);
  603.             aControl->DimState(! enable, kRedraw);
  604.  
  605.             break;
  606.  
  607.         case kRadioButtonDlgIndex:
  608.  
  609.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN1'));
  610.             aControl->SetEnable(enable);
  611.             aControl->DimState(! enable, kRedraw);
  612.             
  613.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN2'));
  614.             aControl->SetEnable(enable);
  615.             aControl->DimState(! enable, kRedraw);
  616.             
  617.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('BTN3'));
  618.             aControl->SetEnable(enable);
  619.             aControl->DimState(! enable, kRedraw);
  620.             
  621.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN1'));
  622.             aControl->SetEnable(enable);
  623.             aControl->DimState(! enable, kRedraw);
  624.             
  625.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN2'));
  626.             aControl->SetEnable(enable);
  627.             aControl->DimState(! enable, kRedraw);
  628.             
  629.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN3'));
  630.             aControl->SetEnable(enable);
  631.             aControl->DimState(! enable, kRedraw);
  632.  
  633.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN4'));
  634.             aControl->SetEnable(enable);
  635.             aControl->DimState(! enable, kRedraw);
  636.  
  637.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN5'));
  638.             aControl->SetEnable(enable);
  639.             aControl->DimState(! enable, kRedraw);
  640.  
  641.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN6'));
  642.             aControl->SetEnable(enable);
  643.             aControl->DimState(! enable, kRedraw);
  644.  
  645.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('ICN7'));
  646.             aControl->SetEnable(enable);
  647.             aControl->DimState(! enable, kRedraw);
  648.  
  649.             break;
  650.  
  651.         case kScrollBarDlgIndex:
  652.  
  653.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('SBAR'));
  654.             aControl->SetEnable(enable);
  655.             aControl->DimState(! enable, kRedraw);
  656.  
  657.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('HSBR'));
  658.             aControl->SetEnable(enable);
  659.             aControl->DimState(! enable, kRedraw);
  660.  
  661.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('VSBR'));
  662.             aControl->SetEnable(enable);
  663.             aControl->DimState(! enable, kRedraw);
  664.  
  665.             break;
  666.  
  667.         case kSliderDlgIndex:
  668.  
  669.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('VSPL'));
  670.             aControl->SetEnable(enable);
  671.             aControl->DimState(! enable, kRedraw);
  672.             
  673.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('VSPR'));
  674.             aControl->SetEnable(enable);
  675.             aControl->DimState(! enable, kRedraw);
  676.             
  677.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('VSRC'));
  678.             aControl->SetEnable(enable);
  679.             aControl->DimState(! enable, kRedraw);
  680.             
  681.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('HSPL'));
  682.             aControl->SetEnable(enable);
  683.             aControl->DimState(! enable, kRedraw);
  684.             
  685.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('HSPR'));
  686.             aControl->SetEnable(enable);
  687.             aControl->DimState(! enable, kRedraw);
  688.             
  689.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('HSRC'));
  690.             aControl->SetEnable(enable);
  691.             aControl->DimState(! enable, kRedraw);
  692.  
  693.             break;
  694.  
  695.         case kPopupMenuDlgIndex:
  696.  
  697.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('POP1'));
  698.             aControl->SetEnable(enable);
  699.             aControl->DimState(! enable, kRedraw);
  700.  
  701.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('POP2'));
  702.             aControl->SetEnable(enable);
  703.             aControl->DimState(! enable, kRedraw);
  704.  
  705.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('POP3'));
  706.             aControl->SetEnable(enable);
  707.             aControl->DimState(! enable, kRedraw);
  708.  
  709.             break;
  710.  
  711.         case kGroupBoxDlgIndex:
  712.  
  713.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('GRP1'));
  714.             aControl->SetEnable(enable);
  715.             aControl->DimState(! enable, kRedraw);
  716.  
  717.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('GR1A'));
  718.                 aControl->SetEnable(enable);
  719.                 aControl->DimState(! enable, kRedraw);
  720.  
  721.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R1A1'));
  722.                     aControl->SetEnable(enable);
  723.                     aControl->DimState(! enable, kRedraw);
  724.  
  725.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R1A2'));
  726.                     aControl->SetEnable(enable);
  727.                     aControl->DimState(! enable, kRedraw);
  728.  
  729.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('GR1B'));
  730.                 aControl->SetEnable(enable);
  731.                 aControl->DimState(! enable, kRedraw);
  732.  
  733.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R1B1'));
  734.                     aControl->SetEnable(enable);
  735.                     aControl->DimState(! enable, kRedraw);
  736.  
  737.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R1B2'));
  738.                     aControl->SetEnable(enable);
  739.                     aControl->DimState(! enable, kRedraw);
  740.  
  741.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('GRP2'));
  742.             aControl->SetEnable(enable);
  743.             aControl->DimState(! enable, kRedraw);
  744.  
  745.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('GR2A'));
  746.                 aControl->SetEnable(enable);
  747.                 aControl->DimState(! enable, kRedraw);
  748.  
  749.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R2A1'));
  750.                     aControl->SetEnable(enable);
  751.                     aControl->DimState(! enable, kRedraw);
  752.  
  753.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R2A2'));
  754.                     aControl->SetEnable(enable);
  755.                     aControl->DimState(! enable, kRedraw);
  756.  
  757.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('GR2B'));
  758.                 aControl->SetEnable(enable);
  759.                 aControl->DimState(! enable, kRedraw);
  760.  
  761.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R2B1'));
  762.                     aControl->SetEnable(enable);
  763.                     aControl->DimState(! enable, kRedraw);
  764.  
  765.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R2B2'));
  766.                     aControl->SetEnable(enable);
  767.                     aControl->DimState(! enable, kRedraw);
  768.  
  769.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('CBX1'));
  770.             aControl->SetEnable(enable);
  771.             aControl->DimState(! enable, kRedraw);
  772.  
  773.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('GRP3'));
  774.             aControl->SetEnable(enable);
  775.             aControl->DimState(! enable, kRedraw);
  776.  
  777.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('CBX2'));
  778.                 aControl->SetEnable(enable);
  779.                 aControl->DimState(! enable, kRedraw);
  780.  
  781.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('GR3A'));
  782.                 aControl->SetEnable(enable);
  783.                 aControl->DimState(! enable, kRedraw);
  784.  
  785.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R3A1'));
  786.                     aControl->SetEnable(enable);
  787.                     aControl->DimState(! enable, kRedraw);
  788.  
  789.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R3A2'));
  790.                     aControl->SetEnable(enable);
  791.                     aControl->DimState(! enable, kRedraw);
  792.  
  793.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('CBX3'));
  794.                 aControl->SetEnable(enable);
  795.                 aControl->DimState(! enable, kRedraw);
  796.  
  797.                 FailNIL(aControl = (TControl*) itsWindow->FindSubView('GR3B'));
  798.                 aControl->SetEnable(enable);
  799.                 aControl->DimState(! enable, kRedraw);
  800.  
  801.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R3B1'));
  802.                     aControl->SetEnable(enable);
  803.                     aControl->DimState(! enable, kRedraw);
  804.  
  805.                     FailNIL(aControl = (TControl*) itsWindow->FindSubView('R3B2'));
  806.                     aControl->SetEnable(enable);
  807.                     aControl->DimState(! enable, kRedraw);
  808.  
  809.             break;
  810.  
  811.         case kFolderTabsDlgIndex:
  812.  
  813.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('TAB1'));
  814.             aControl->SetEnable(enable);
  815.             aControl->DimState(! enable, kRedraw);
  816.  
  817.             FailNIL(aControl = (TControl*) itsWindow->FindSubView('TAB2'));
  818.             aControl->SetEnable(enable);
  819.             aControl->DimState(! enable, kRedraw);
  820.  
  821.             break;
  822.  
  823.         case kFocusBorderDlgIndex:
  824.  
  825.             FailNIL(aView = itsWindow->FindSubView('BRD1'));
  826.             aView->SetEnable(enable);
  827.             aView->ForceRedraw();
  828.  
  829.             FailNIL(aView = itsWindow->FindSubView('BRD2'));
  830.             aView->SetEnable(enable);
  831.             aView->ForceRedraw();
  832.  
  833.             FailNIL(aView = itsWindow->FindSubView('BRD3'));
  834.             aView->SetEnable(enable);
  835.             aView->ForceRedraw();
  836.  
  837.             FailNIL(aView = itsWindow->FindSubView('TVW1'));
  838.             aView->SetEnable(enable);
  839.             aView->ForceRedraw();
  840.  
  841.             FailNIL(aView = itsWindow->FindSubView('TVW2'));
  842.             aView->SetEnable(enable);
  843.             aView->ForceRedraw();
  844.  
  845.             FailNIL(aView = itsWindow->FindSubView('TVW3'));
  846.             aView->SetEnable(enable);
  847.             aView->ForceRedraw();
  848.  
  849.             break;
  850.  
  851.         }
  852.     }
  853.  
  854. void TMyApplication::DoAboutBox()
  855.     {
  856.     TWindow*        aWindow;
  857.     TStaticText*    copyrightString;
  858.  
  859.     FailNIL(aWindow = gViewServer->NewTemplateWindow(kAboutBoxViewID, NULL));
  860.     
  861.     FailNIL(copyrightString = (TStaticText*) aWindow->FindSubView('COPY'));
  862.     copyrightString->SetText(gGrayCouncilCopyright, kDontRedraw);
  863.     
  864.     (void) aWindow->PoseModally();
  865.     
  866.     aWindow->CloseAndFree();
  867.     }
  868.